﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinProgProject2
{
    public partial class Giris : Form
    {
        bool dikeyYon = false;
        bool yatayYon = false;
        bool dikeyYon2 = true;
        bool yatayYon2= false;
        bool dikeyYon3 = false;
        bool yatayYon3 = true;
        public Giris()
        {
            InitializeComponent();
        }

        private void Giris_Load(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            pic1Move();
            pic2Move();
            pic3Move();
        }

        public void pic1Move()
        {
            if (pb1.Right == pbMain.Right-62)
                yatayYon = true;
            if (pb1.Left == pbMain.Left)
                yatayYon = false;
            if (pb1.Bottom == pbMain.Bottom-57)
                dikeyYon = true;
            if (pb1.Top == pbMain.Top)
                dikeyYon = false;

            yatayArttirAzalt(pb1, yatayYon);
            dikeyArttirAzalt(pb1, dikeyYon);
        }

        public void pic2Move()
        {
            if (pb2.Location.X == pbMain.Right - 1 - 62)
                yatayYon2 = true;
            if (pb2.Location.X == pbMain.Left + 1)
                yatayYon2 = false;
            if (pb2.Location.Y == pbMain.Bottom - 1 - 57)
                dikeyYon2 = true;
            if (pb2.Location.Y == pbMain.Top + 1)
                dikeyYon2 = false;

            yatayArttirAzalt(pb2, yatayYon2);
            dikeyArttirAzalt(pb2, dikeyYon2);
        }

        public void pic3Move()
        {
            if (pb3.Location.X == pbMain.Right - 1 - 62)
                yatayYon3 = true;
            if (pb3.Location.X == pbMain.Left + 1)
                yatayYon3 = false;
            if (pb3.Location.Y == pbMain.Bottom - 1 - 57)
                dikeyYon3 = true;
            if (pb3.Location.Y == pbMain.Top + 1)
                dikeyYon3 = false;

            yatayArttirAzalt(pb3, yatayYon3);
            dikeyArttirAzalt(pb3, dikeyYon3);
        }

        public void yatayArttirAzalt(PictureBox pb,bool yon)
        {
            if (yon)
                pb.Left--;
            else pb.Left++;
        }

        public void dikeyArttirAzalt(PictureBox pb, bool yon)
        {
            if (yon)
                pb.Top--;
            else pb.Top++;
        }

        private void Giris_FormClosing(object sender, FormClosingEventArgs e)
        {
            timer1.Stop();
        }
    }
}
